package com.gitee.minimalismstyle.fresh.simple.api.model

import com.google.common.base.CaseFormat
import java.math.BigDecimal
import java.util.*

class TableSchema {
    companion object{
        private val COLUMN_PKG = listOf<String>(
            BigDecimal::class.java.name,
            Date::class.java.name
        )
    }
    var name: String? = null
        set(value) {
            field = value
            objectName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, value!!)
            className = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, value)
        }

    var comment: String? = null

    var className: String? = null

    var objectName: String? = null

    var packageClassName: String? = null

    var pk: TableColumnSchema = TableColumnSchema()

    var columnPkgs: MutableSet<String> = mutableSetOf()

    var columns: List<TableColumnSchema> = arrayListOf()
        set(value) {
            field = value
            value.forEach {
                if(COLUMN_PKG.contains(it.fieldFullType)){
                    columnPkgs.add(it.fieldFullType!!)
                }
            }
        }
}
